package com.mengmeng.quicklymessage;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

public class TestActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        Bundle bundle = getIntent().getExtras();
        // String[] contents = bundle.getStringArray(Constant.KEY_MESSAGE);
        String content = bundle.getString(Constant.KEY_MESSAGE);
        String number = bundle.getString(Constant.KEY_NUMBER);
        sendMessage(number, content);
        finish();
        super.onCreate(savedInstanceState);
    }

    private void sendMessage(String number, String content) {
        Log.v("xxx", "number===" + number);
        SmsManager smsMgr = SmsManager.getDefault();
        Log.v("xxx", "sendMessage");
        if (content != null && !TextUtils.isEmpty(content)) {
            Log.v("xxx", "sendMessaged");

            smsMgr.sendTextMessage(number, null, content, null, null);
            Toast.makeText(this, getString(R.string.send_completed), 200)
                    .show();
        }
    }

}
